package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *  锁 测试
 */
@RestController
@RequestMapping("/admin/product/")
public class TestController {

    @Autowired
    private TestService testService;
    //测试
    @GetMapping("/test/testLock")
    public Result testLock(){
        //测试
        testService.testLock();
        return Result.ok();
    }

    //分布式上锁
    @GetMapping("/test/testLockMethod")
    public Result testLockMethod(){
        //测试
        testService.testLockMethod();
        return Result.ok();
    }

    //读
    @GetMapping("read")
    public Result read(){
        String msg = testService.testRead();
        return Result.ok(msg);
    }

    //写
    @GetMapping("write")
    public Result write(){
        String msg = testService.testWrite();
        return Result.ok(msg);
    }
}
